package com.ygxsk.carhome.ui.archive;

import android.Manifest;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.NetworkUtils;
import com.blankj.utilcode.util.StringUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemChildClickListener;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.flyco.roundview.RoundTextView;
import com.gyf.immersionbar.ImmersionBar;
import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.XXPermissions;
import com.hjq.toast.Toaster;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshListener;
import com.trello.rxlifecycle4.android.ActivityEvent;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.constant.ConstantApi;
import com.ygxsk.carhome.constant.ConstantSign;
import com.ygxsk.carhome.constant.ExtraKey;
import com.ygxsk.carhome.constant.ExtraValue;
import com.ygxsk.carhome.enumwrap.CallHistoryBusinessType;
import com.ygxsk.carhome.enumwrap.InfoMationAuditStatus;
import com.ygxsk.carhome.enumwrap.LeadGender;
import com.ygxsk.carhome.event.EventArchiveDetail;
import com.ygxsk.carhome.listener.AuthorityCallbackListener;
import com.ygxsk.carhome.listener.Delivery;
import com.ygxsk.carhome.listener.ErrorParentExtraSingle;
import com.ygxsk.carhome.response.ArchivesManageFileMy;
import com.ygxsk.carhome.response.ArchivesManageVo;
import com.ygxsk.carhome.response.CarInfoVehicleBean;
import com.ygxsk.carhome.response.ClientManageVo;
import com.ygxsk.carhome.response.InformationAccessoryUpLoad;
import com.ygxsk.carhome.response.InformationAccessoryVo;
import com.ygxsk.carhome.response.InformationManage;
import com.ygxsk.carhome.response.InformationManageVo;
import com.ygxsk.carhome.retrofit.AddLogUpLoadInfo;
import com.ygxsk.carhome.retrofit.ApiException;
import com.ygxsk.carhome.retrofit.ApiRequestSubListener;
import com.ygxsk.carhome.retrofit.ApiService;
import com.ygxsk.carhome.retrofit.ErrorConsumer;
import com.ygxsk.carhome.retrofit.NetworkManager;
import com.ygxsk.carhome.retrofit.ResponseTransformer;
import com.ygxsk.carhome.sys.PermissionInterceptor;
import com.ygxsk.carhome.sys.PermissionNameConvert;
import com.ygxsk.carhome.ui.ErrorActivity;
import com.ygxsk.carhome.ui.adapter.ArchiveDetailAgreenAdapter;
import com.ygxsk.carhome.ui.adapter.ArchiveDetailFootAdapter;
import com.ygxsk.carhome.ui.adapter.ArchiveFileCarInfoDetailAdapter;
import com.ygxsk.carhome.utils.CommTools;
import com.ygxsk.carhome.utils.CommUtils;
import com.ygxsk.carhome.utils.StringCodeUtils;
import com.ygxsk.carhome.views.MyLinearLayoutManager;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import butterknife.BindView;
import cn.bingoogolapple.photopicker.widget.BGANinePhotoLayout;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.functions.Consumer;
import pub.devrel.easypermissions.AfterPermissionGranted;
import pub.devrel.easypermissions.EasyPermissions;

/*
 * @Author:itchenqi175@163.com
 * @Time:2023-07-27  20:43
 * @Description:档案管理的适配器页面
 */
public class ArchiveDetailActivity extends ErrorActivity implements ErrorParentExtraSingle, EasyPermissions.PermissionCallbacks {

    //填充适配器；
    //下拉刷新 详情
//    @BindView(R.id.refreshlayoutauthmanagedetail)
//    SmartRefreshLayout refreshLayoutAuthManageDetail;

    private static final int PRC_PHOTO_PREVIEW = 1;

    //客户姓名
    private TextView textViewCustomerPersonName;
    //客户性别
    private TextView textViewCustomerPersonSex;
    //客户年龄
    private TextView textViewCustomerPersonYear;
    //客户电话
    private TextView textViewCustomerPersonPhone;
    //外侧的电话号码，用于详情内的拨打用到
    private String phoneNumber_outSide;
    //微信号
    private TextView textViewCustomerPersonWechat;
    //邮箱信息
    private TextView textViewCustomerPersonEmail;
    //地址信息 住址？
    private TextView textViewCustomerPersonAddress;
    //公司信息
    private TextView textViewCustomerPersonCompany;
    //公司信息
    private TextView textViewCustomerPersonJob;

    //------------------------------------------
//    //车牌号
//    private TextView textViewFileCarCard;
//
//    //车架号码
//    private TextView textViewFileCarFrame;
//
//    //发动机号
//    private TextView textViewFileCarMotor;
//
//    //品牌型号
//    private TextView textViewFileCarBrandModel;
//
//    //车辆车系
//    private TextView textViewFileCarModelLine;
//
//    //车辆型号
//    private TextView textViewFileCarModelSmall;

    private BGANinePhotoLayout npl_item_moment_photos_file_detail;

    @BindView(R.id.refreshlayoutinarchivedetail)
    SmartRefreshLayout refreshLayoutInArchiveDetail;

    @BindView(R.id.recyclerviewinarchivedetail)
    RecyclerView recyclerViewInArchiveDetail;

    //该页面适配器
    private ArrayList<ArchivesManageVo> mDataResources = new ArrayList<>();
    //车辆的多车辆列表
    private ArrayList<CarInfoVehicleBean> mDataResources_vehicleList = new ArrayList<>();
    //档案附件 九宫格的图片内容
    private ArrayList<ArchivesManageFileMy> mDataResources_archivesManageFileMy = new ArrayList<>();

    //添加底部九宫格的附件的适配器；
    private ArchiveDetailFootAdapter archiveDetailFootAdapter;

    //详情之中车辆的适配器
    private ArchiveFileCarInfoDetailAdapter archiveFileCarInfoDetailAdapter;

    //适配器
    private ArchiveDetailAgreenAdapter archiveDetailAgreenAdapter;

    //携带的 从列表过来的这条数据,合同信息这一条的
    private InformationManage extra_information_manage;

    //本地做一个详情记录，为了判断【按钮是否可点击】
    private InformationManageVo informationManageVo_temp_local;

    //携带详情的信息过去主要的是为了修改 客户信息和车辆信息
    private InformationManageVoExtra extra_informationManageVoExtra;

    private BGANinePhotoLayout mCurrentClickNpl;

    //给列表九宫格查看准备
    private BGANinePhotoLayout.Delegate bgaNinePhotoLayoutDelegate = new BGANinePhotoLayout.Delegate() {
        @Override
        public void onClickNinePhotoItem(BGANinePhotoLayout ninePhotoLayout, View view, int position, String model, List<String> models) {
            //点击九宫格,查看大图
            mCurrentClickNpl = ninePhotoLayout;

            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {

                photoPreviewWrapper();

            } else {

                photoPreviewIntentXXPermissions();

            }
        }

        @Override
        public void onClickExpand(BGANinePhotoLayout ninePhotoLayout, View view, int position, String model, List<String> models) {
            //点击展开的
            ninePhotoLayout.setIsExpand(true);
            ninePhotoLayout.flushItems();
        }
    };


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mActivityInstance = this;

        if (extra_informationManageVoExtra == null) {
            extra_informationManageVoExtra = new InformationManageVoExtra();
        }

        if (mDataResources_archivesManageFileMy == null) {
            mDataResources_archivesManageFileMy = new ArrayList<>();
        }

        processExtraData();

        initloading();

        initViews();

        gainDatas();

        //因为修改要监听刷新详情的
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }


    }

    protected void initImmersionBar() {
        super.initImmersionBar();

        ImmersionBar.with(this)//
                .titleBar(R.id.toolbarygxskout)
                .fitsSystemWindows(true)//解决状态栏和布局重叠问题，任选其一，默认为false，当为true时一定要指定statusBarColor()，不然状态栏为透明色，还有一些重载方法
                //.statusBarColor(R.color.colorPrimary)//
                //.navigationBarColor(R.color.colorPrimary)//
//                .keyboardEnable(true)
                .init();

    }

    @Override
    protected int getContentViewId() {
        return R.layout.activity_archive_detail;
    }

    @Override
    protected void initToolBar(ToolbarHelper toolbarHelper) {

        //这个可能是动态的，不同身份 是不同标题：服务站经理存款业绩排名
        toolbarHelper.setTitle(getString(R.string.title_agreen_detail));
        toolbarHelper.setVersionName(true, AppUtils.getAppVersionName());
        toolbarHelper.setLayoutClose(false, "", null);
        toolbarHelper.setLayoutLeft(true, R.drawable.backicon, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                methodBack();
            }
        });

        toolbarHelper.setLayoutRight(false, 0, "", null);

//        toolbarHelper.setLayoutRight(true, 1, "添加", new ClickUtils.OnDebouncingClickListener() {
//            @Override
//            public void onDebouncingClick(View v) {
//                //历史记录的页面布局
//                Bundle extra_bundle = new Bundle();
//                //这里空携带
//                ActivityUtils.startActivity(extra_bundle, RunManOpenCardEditActivity.class);
//            }
//        });

    }

    @Override
    protected void onClickNodata(View v) {

        gainDatas();

    }

    @Override
    protected void initViews() {

//        ArichiveDetailBean arichiveDetailBean = new ArichiveDetailBean();
//        arichiveDetailBean.setAgreenTypeInfo("购车合同");

        //布局的适配器填充，下拉刷新等等；
        recyclerViewInArchiveDetail.setLayoutManager(new MyLinearLayoutManager(this));
        archiveDetailAgreenAdapter = new ArchiveDetailAgreenAdapter(R.layout.archivedetailadapter, mDataResources, extra_information_manage.getAuditStatus());
        recyclerViewInArchiveDetail.setAdapter(archiveDetailAgreenAdapter);

        //字段内容是 顶部的header内容
        archiveDetailAgreenAdapter.removeAllHeaderView();
        archiveDetailAgreenAdapter.removeAllFooterView();

        archiveDetailAgreenAdapter.addHeaderView(getHeaderView(recyclerViewInArchiveDetail));
        archiveDetailAgreenAdapter.addFooterView(getFooterViewIsList(recyclerViewInArchiveDetail));
//        archiveDetailAgreenAdapter.addFooterView(getFooterView(recyclerViewInArchiveDetail));

        archiveDetailAgreenAdapter.notifyDataSetChanged();

        archiveDetailAgreenAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {

                ArchivesManageVo archivesManageVo = (ArchivesManageVo) adapter.getItem(position);

                //直接携带整个详情过去
                if (archivesManageVo != null) {

                    Bundle extra_bundle = new Bundle();

                    //携带这条合同的id，过去--这种改造携带过去肯定是空吗，因为id变了
//                    String archivesManageVo_id = archivesManageVo.getArchivesId();
                    String archivesManageVo_id = archivesManageVo.getArchivesId();

                    //这里取值  getInformationId
//                    String archivesManageVo_id = archivesManageVo.getInformationId();

                    //直接携带车辆档案id，是这个车辆档案的这个合同；
                    extra_bundle.putString(ExtraKey.EXTRA_ARCHIVESMANAGEVO_ID, archivesManageVo_id);

                    //携带这个档案的id,目的是到了合同详情页，获取整个档案的详情
//                    extra_bundle.putString(ExtraKey.EXTRA_VEHICLEID_ID, extra_information_manage.getVehicleId());

//                    extra_bundle.putParcelable(ExtraKey.EXTRA_INFORMATION_MANAGE, extra_information_manage);
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL + "--extra_information_manage.getVehicleId()-->" + extra_information_manage.getVehicleId());

                    ActivityUtils.startActivity(extra_bundle, AgreenMentDetailActivity.class);

                } else {
                    ToastUtils.showShort(getString(R.string.action_abnormal));
                }
            }
        });


        //单独的【添加单个合同】
        archiveDetailAgreenAdapter.setOnItemChildClickListener(new OnItemChildClickListener() {
            @Override
            public void onItemChildClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {

                ArchivesManageVo archivesManageVo = (ArchivesManageVo) adapter.getItem(position);

                switch (view.getId()) {

                    case R.id.roundtextvieweditagreenment: {//是单独的 【添加合同】按钮；

                        Bundle extra_bundle = new Bundle();

                        if (extra_information_manage != null) {
                            //添加单个的合同 为了携带 这条档案的id;
                            extra_bundle.putParcelable(ExtraKey.EXTRA_INFORMATION_MANAGE, extra_information_manage);
                        }

                        if (archivesManageVo != null) {
                            //传递一个单独的外侧档案的id过去；
                            extra_bundle.putString(ExtraKey.EXTRA_VEHICLEID_ID, archivesManageVo.getInformationId());
                        }

                        //标志 是 【添加单个合同】过去的,不是【编辑】合同过去的；
                        extra_bundle.putBoolean(ExtraKey.EXTRA_ARCHIVESMANAGE_VO_IS_EDIT, false);

                        ActivityUtils.startActivity(extra_bundle, AgreenMentAddSubmitActivity.class);


                        break;
                    }

                    default:
                        break;
                }

            }
        });


        refreshLayoutInArchiveDetail.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {

                refreshLayout.getLayout().post(new Runnable() {
                    @Override
                    public void run() {

                        if (mDataResources != null && !mDataResources.isEmpty()) {
                            mDataResources.clear();
                        }

                        if (archiveDetailAgreenAdapter != null) {
                            archiveDetailAgreenAdapter.notifyDataSetChanged();
                        }

                        getServerDatas();

                        refreshLayout.finishRefresh();
                    }
                });

            }
        });

    }


    private View getHeaderView(RecyclerView _recyclerViewWork) {

        View workHeader;
        if ((_recyclerViewWork != null) && (_recyclerViewWork.getParent() != null)) {
            workHeader = LayoutInflater.from(ArchiveDetailActivity.this).inflate(//
                    R.layout.archive_file_detail_header, //
                    (ViewGroup) _recyclerViewWork.getParent(),//
                    false);//
        } else {
            workHeader = LayoutInflater.from(ArchiveDetailActivity.this).inflate(R.layout.archive_file_detail_header, null);
        }

        //客户顶部的【编辑】按钮
        RoundTextView roundTextViewEditRightForCustomer = (RoundTextView) workHeader.findViewById(R.id.roundtextvieweditright);

        //客户姓名
        textViewCustomerPersonName = (TextView) workHeader.findViewById(R.id.textviewcustomerpersonname);
        //客户性别
        textViewCustomerPersonSex = (TextView) workHeader.findViewById(R.id.textviewcustomerpersonsex);
        //客户年龄
        textViewCustomerPersonYear = (TextView) workHeader.findViewById(R.id.textviewcustomerpersonyear);
        //客户电话
        textViewCustomerPersonPhone = (TextView) workHeader.findViewById(R.id.textviewcustomerpersonphone);
        //微信号
        textViewCustomerPersonWechat = (TextView) workHeader.findViewById(R.id.textviewcustomerpersonwechat);
        //邮箱信息
        textViewCustomerPersonEmail = (TextView) workHeader.findViewById(R.id.textviewcustomerpersonemail);
        //地址信息 住址？
        textViewCustomerPersonAddress = (TextView) workHeader.findViewById(R.id.textviewcustomerpersonaddress);
        //公司信息
        textViewCustomerPersonCompany = (TextView) workHeader.findViewById(R.id.textviewcustomerpersoncompany);
        //职位信息
        textViewCustomerPersonJob = (TextView) workHeader.findViewById(R.id.textviewcustomerpersonjob);

        //        InfoMationAuditStatus
//                AUDITSTATUS_INPUTING(0, "填写中"), //填写中
//                AUDITSTATUS_TO_BE_VERIFY(1, "待审核"),//待审核
//                AUDITSTATUS_HAS_PASS(2, "通过"),//通过
//                AUDITSTATUS_NOT_PASS(3, "不通过");//不通过

        if (TextUtils.equals(extra_information_manage.getAuditStatus(), String.valueOf(InfoMationAuditStatus.AUDITSTATUS_INPUTING.getIndex()))//
                || TextUtils.equals(extra_information_manage.getAuditStatus(), String.valueOf(InfoMationAuditStatus.AUDITSTATUS_TO_BE_VERIFY.getIndex()))//
                || TextUtils.equals(extra_information_manage.getAuditStatus(), String.valueOf(InfoMationAuditStatus.AUDITSTATUS_NOT_PASS.getIndex()))//
        ) {

            if (roundTextViewEditRightForCustomer != null) {

//                CommUtils.RoundTextViewButtonEnable(roundTextViewEditRightForCustomer);

                roundTextViewEditRightForCustomer.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {

                        //如果是审核通过 不让修改， 待审核 和
                        //跳转到客户编辑的详情页面
                        Bundle extra_bundle = new Bundle();
                        //将整个详情携带过去
                        extra_bundle.putParcelable(ExtraKey.EXTRA_INFORMATION_MANAGE_VO_EXTRA, extra_informationManageVoExtra);
                        //修改客户信息
                        ActivityUtils.startActivity(extra_bundle, CustomerInfoEditActivity.class);

                    }
                });
            }

        } else if (TextUtils.equals(extra_information_manage.getAuditStatus(), String.valueOf(InfoMationAuditStatus.AUDITSTATUS_HAS_PASS.getIndex()))) {

            CommUtils.setViewGone(roundTextViewEditRightForCustomer);

            //如果是审核通过 不让修改， 待审核 和
//            if (roundTextViewEditRightForCustomer != null) {

//                CommUtils.RoundTextViewButtonNotUse(roundTextViewEditRightForCustomer);

//                roundTextViewEditRightForCustomer.setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View v) {
//
//                        String completeStr = getString(R.string.auditstatus_complete);
//                        PopTip.show(completeStr).iconWarning();
//
//                    }
//                });

//            }

        }

//        if (roundTextViewEditRightForCustomer != null) {
//
//            roundTextViewEditRightForCustomer.setOnClickListener(new View.OnClickListener() {
//
//                @Override
//                public void onClick(View v) {
//
////                    InfoMationAuditStatus
////                            AUDITSTATUS_TO_BE_VERIFY(0, "待审核"), //待审核
////                            AUDITSTATUS_COMPLETE(1, "审核通过"),//审核通过
////                            AUDITSTATUS_NOT_PASS(2, "不通过");//不通过
//
//                    //如果是审核通过 不让修改， 待审核 和
//                    //跳转到客户编辑的详情页面
//                    Bundle extra_bundle = new Bundle();
//
//                    //将整个详情携带过去
//                    extra_bundle.putParcelable(ExtraKey.EXTRA_INFORMATION_MANAGE_VO_EXTRA, extra_informationManageVoExtra);
//
//                    //修改客户信息
//                    ActivityUtils.startActivity(extra_bundle, CustomerInfoEditActivity.class);
//
////                    if (informationManageVo_temp_local.getAuditStatus() == InfoMationAuditStatus.AUDITSTATUS_TO_BE_VERIFY.getIndex()
////                            || informationManageVo_temp_local.getAuditStatus() == InfoMationAuditStatus.AUDITSTATUS_NOT_PASS.getIndex()) {
////                        //跳转到客户编辑的详情页面
////                        Bundle extra_bundle = new Bundle();
////                        //将整个详情携带过去
////                        extra_bundle.putParcelable(ExtraKey.EXTRA_INFORMATION_MANAGE_VO_EXTRA, extra_informationManageVoExtra);
////                        ActivityUtils.startActivity(extra_bundle, CustomerInfoEditActivity.class);
////
////                    } else if (informationManageVo_temp_local.getAuditStatus() == InfoMationAuditStatus.AUDITSTATUS_COMPLETE.getIndex()) {
////                        String completeStr = getString(R.string.auditstatus_complete);
////                        PopTip.show(completeStr).iconWarning();
////
////                    }
//
//                }
//            });
//        }

        //拨打电话的按钮
        textViewCustomerPersonPhone.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                clickButton_toCallPhone(ArchiveDetailActivity.this, phoneNumber_outSide, CallHistoryBusinessType.BUSINESSTYPE_7.getIndex());
            }
        });

        //--------------------------------------------------------------------------------------------
        //--------------------------------------------------------------------------------------------
        //--------------------------------------------------------------------------------------------------------------------------
        //车辆时多车辆信息
        RecyclerView recyclerViewCarInfoDetailMore = (RecyclerView) workHeader.findViewById(R.id.recyclerviewcarinfodetailmore);
        recyclerViewCarInfoDetailMore.setLayoutManager(new MyLinearLayoutManager(ArchiveDetailActivity.this));

        //车辆列表的适配器
        archiveFileCarInfoDetailAdapter = new ArchiveFileCarInfoDetailAdapter(R.layout.filedetailmiddle_item, mDataResources_vehicleList, extra_information_manage.getAuditStatus());
        recyclerViewCarInfoDetailMore.setAdapter(archiveFileCarInfoDetailAdapter);
        archiveFileCarInfoDetailAdapter.notifyDataSetChanged();

        archiveFileCarInfoDetailAdapter.setOnItemChildClickListener(new OnItemChildClickListener() {
            @Override
            public void onItemChildClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {

                //
                CarInfoVehicleBean _carInfoVehicleBean = (CarInfoVehicleBean) adapter.getItem(position);

                //    InfoMationAuditStatus
//                            AUDITSTATUS_TO_BE_VERIFY(0, "待审核"), //待审核
//                            AUDITSTATUS_COMPLETE(1, "审核通过"),//审核通过
//                            AUDITSTATUS_NOT_PASS(2, "不通过");//不通过

                //如果是审核通过 不让修改， 待审核 和
                //跳转到客户编辑的详情页面
                Bundle extra_bundle = new Bundle();

                //将整个详情携带过去
                extra_bundle.putParcelable(ExtraKey.EXTRA_INFORMATION_MANAGE_VO_EXTRA, _carInfoVehicleBean);

                LogUtils.json(ConstantSign.LOGCAT_NOMAL + "即将携带->", _carInfoVehicleBean);

                ActivityUtils.startActivity(extra_bundle, CarInfoEditActivity.class);

//                    if (informationManageVo_temp_local.getAuditStatus() == InfoMationAuditStatus.AUDITSTATUS_TO_BE_VERIFY.getIndex()
//                            || informationManageVo_temp_local.getAuditStatus() == InfoMationAuditStatus.AUDITSTATUS_NOT_PASS.getIndex()) {
//
//                        //跳转到客户编辑的详情页面
//                        Bundle extra_bundle = new Bundle();
//                        //将整个详情携带过去
//                        extra_bundle.putParcelable(ExtraKey.EXTRA_INFORMATION_MANAGE_VO_EXTRA, extra_informationManageVoExtra);
//                        ActivityUtils.startActivity(extra_bundle, CarInfoEditActivity.class);
//
//                    } else if (informationManageVo_temp_local.getAuditStatus() == InfoMationAuditStatus.AUDITSTATUS_COMPLETE.getIndex()) {
//
//                        String completeStr = getString(R.string.auditstatus_complete);
//                        PopTip.show(completeStr).iconWarning();
//
//                    }

            }
        });

        //--------------------------------------------------------------------------------------------------------------------------

//        //编辑车辆信息的按钮
//        RoundTextView roundTextViewEditCarInfoRight = (RoundTextView) workHeader.findViewById(R.id.roundtextvieweditcarinforight);
//        //车牌号
//        textViewFileCarCard = (TextView) workHeader.findViewById(R.id.textviewfilecarcard);
//        //车架号码
//        textViewFileCarFrame = (TextView) workHeader.findViewById(R.id.textviewfilecarframe);
//        //发动机号
//        textViewFileCarMotor = (TextView) workHeader.findViewById(R.id.textviewfilecarmotor);
//        //品牌型号
//        textViewFileCarBrandModel = (TextView) workHeader.findViewById(R.id.textviewfilecarbrandmodel);
//        //车辆车系
//        textViewFileCarModelLine = (TextView) workHeader.findViewById(R.id.textviewfilecarmodelline);
//        //车辆型号
//        textViewFileCarModelSmall = (TextView) workHeader.findViewById(R.id.textviewfilecarmodelsmall);
//
//        if (roundTextViewEditCarInfoRight != null) {
//            roundTextViewEditCarInfoRight.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View v) {
//
//                    //    InfoMationAuditStatus
////                            AUDITSTATUS_TO_BE_VERIFY(0, "待审核"), //待审核
////                            AUDITSTATUS_COMPLETE(1, "审核通过"),//审核通过
////                            AUDITSTATUS_NOT_PASS(2, "不通过");//不通过
//
//                    //如果是审核通过 不让修改， 待审核 和
//                    //跳转到客户编辑的详情页面
//                    Bundle extra_bundle = new Bundle();
//                    //将整个详情携带过去
//                    extra_bundle.putParcelable(ExtraKey.EXTRA_INFORMATION_MANAGE_VO_EXTRA, extra_informationManageVoExtra);
//                    ActivityUtils.startActivity(extra_bundle, CarInfoEditActivity.class);
//
////                    if (informationManageVo_temp_local.getAuditStatus() == InfoMationAuditStatus.AUDITSTATUS_TO_BE_VERIFY.getIndex()
////                            || informationManageVo_temp_local.getAuditStatus() == InfoMationAuditStatus.AUDITSTATUS_NOT_PASS.getIndex()) {
////
////                        //跳转到客户编辑的详情页面
////                        Bundle extra_bundle = new Bundle();
////                        //将整个详情携带过去
////                        extra_bundle.putParcelable(ExtraKey.EXTRA_INFORMATION_MANAGE_VO_EXTRA, extra_informationManageVoExtra);
////                        ActivityUtils.startActivity(extra_bundle, CarInfoEditActivity.class);
////
////                    } else if (informationManageVo_temp_local.getAuditStatus() == InfoMationAuditStatus.AUDITSTATUS_COMPLETE.getIndex()) {
////
////                        String completeStr = getString(R.string.auditstatus_complete);
////                        PopTip.show(completeStr).iconWarning();
////
////                    }
//
//                }
//            });
//        }

        return workHeader;

    }

    private View getFooterViewIsList(RecyclerView _recyclerViewWork) {

        View workFooter;

        if ((_recyclerViewWork != null) && (_recyclerViewWork.getParent() != null)) {
            workFooter = LayoutInflater.from(ArchiveDetailActivity.this).inflate(//
                    R.layout.filedetaillistfooter, //
                    (ViewGroup) _recyclerViewWork.getParent(),//
                    false);//
        } else {
            workFooter = LayoutInflater.from(ArchiveDetailActivity.this).inflate(R.layout.filedetaillistfooter, null);
        }

        //list
        RecyclerView recyclerViewInArchiveTypeNine = (RecyclerView) workFooter.findViewById(R.id.recyclerviewinarchivetypenine);
        recyclerViewInArchiveTypeNine.setLayoutManager(new MyLinearLayoutManager(ArchiveDetailActivity.this));

        //adapter
//        ArchiveDetailFootAdapter archiveDetailFootAdapter = new ArchiveDetailFootAdapter(R.layout.filedetailfootadapter, mDataResources_archivesManageFileMy);
        archiveDetailFootAdapter = new ArchiveDetailFootAdapter(R.layout.filedetailfootadapter, mDataResources_archivesManageFileMy, extra_information_manage.getAuditStatus());

        if (bgaNinePhotoLayoutDelegate != null) {
            archiveDetailFootAdapter.setBgaNinePhotoLayoutDelegate(bgaNinePhotoLayoutDelegate);
        }

        recyclerViewInArchiveTypeNine.setAdapter(archiveDetailFootAdapter);
        archiveDetailFootAdapter.notifyDataSetChanged();

        //档案附件编辑的能力
        archiveDetailFootAdapter.setOnItemChildClickListener(new OnItemChildClickListener() {
            @Override
            public void onItemChildClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {

                switch (view.getId()) {

                    case R.id.roundtextvieweditimagesitem: {

                        ArchivesManageFileMy archivesManageFileMy = (ArchivesManageFileMy) adapter.getItem(position);

                        //标题的类型
//                        String fileTypeName = archivesManageFileMy.getFileTypeName();
                        //附件和标题的类型
//                        int fileType = archivesManageFileMy.getFileType();

                        if (archivesManageFileMy != null) {

                            //九宫格的信息携带，主要是图片信息，要填充加载到本地，
                            Bundle extra_bundle = new Bundle();

                            //将整个详情携带过去
                            extra_bundle.putParcelable(ExtraKey.EXTRA_INFORMATION_MANAGE_VO_EXTRA, extra_informationManageVoExtra);
                            extra_bundle.putParcelable(ExtraKey.EXTRA_ARCHIVES_MANAGEFILE_MY, archivesManageFileMy);
                            extra_bundle.putInt(ExtraKey.EXTRA_ARCHIVESMANAGE_FILETYPE, archivesManageFileMy.getFileType());

//                          ActivityUtils.startActivity(extra_bundle, ArchiveImagesActivity.class);
                            ActivityUtils.startActivity(extra_bundle, ArchiveImageFileTypeActivity.class);

                        }

                        break;
                    }

                    default:
                        break;
                }


            }
        });

        return workFooter;
    }

//    private View getFooterView(RecyclerView _recyclerViewWork) {
//
//        View workFooter;
//        if ((_recyclerViewWork != null) && (_recyclerViewWork.getParent() != null)) {
//            workFooter = LayoutInflater.from(ArchiveDetailActivity.this).inflate(//
//                    R.layout.filedetailfooter, //
//                    (ViewGroup) _recyclerViewWork.getParent(),//
//                    false);//
//        } else {
//            workFooter = LayoutInflater.from(ArchiveDetailActivity.this).inflate(R.layout.filedetailfooter, null);
//        }
//
////        BGANinePhotoLayout npl_item_moment_photos_file_detail = (BGANinePhotoLayout) workFooter.findViewById(R.id.npl_item_moment_photos_file_detail);
//        RoundTextView roundTextViewEditImages = (RoundTextView) workFooter.findViewById(R.id.roundtextvieweditimages);
//        //顶部【编辑】图片内容
//        npl_item_moment_photos_file_detail = (BGANinePhotoLayout) workFooter.findViewById(R.id.npl_item_moment_photos_file_detail);
//        //TextView textViewHelpInFileDetail = (TextView)workFooter.findViewById(R.id.textviewhelpinfiledetail);
//
//        if (roundTextViewEditImages != null) {
//            roundTextViewEditImages.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View v) {
//
//                    Bundle extra_bundle = new Bundle();
//                    //将整个详情携带过去
//                    extra_bundle.putParcelable(ExtraKey.EXTRA_INFORMATION_MANAGE_VO_EXTRA, extra_informationManageVoExtra);
//                    ActivityUtils.startActivity(extra_bundle, ArchiveImagesActivity.class);
//
//                }
//            });
//        }
//
//        npl_item_moment_photos_file_detail.setDelegate(new BGANinePhotoLayout.Delegate() {
//            @Override
//            public void onClickNinePhotoItem(BGANinePhotoLayout ninePhotoLayout, View view, int position, String model, List<String> models) {
//
//                mCurrentClickNpl = ninePhotoLayout;
//
//                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
//
//                    photoPreviewWrapper();
//
//                } else {
//
//                    photoPreviewIntentXXPermissions();
//
//                }
//
//            }
//
//            @Override
//            public void onClickExpand(BGANinePhotoLayout ninePhotoLayout, View view, int position, String model, List<String> models) {
//                ninePhotoLayout.setIsExpand(true);
//                ninePhotoLayout.flushItems();
//            }
//        });
//
////        npl_item_moment_photos_file_detail.setData(images);
//
//        //底部帮助布局
//        //CommUtils.methodHelpView4(textViewHelpInFileDetail);
//
//        return workFooter;
//
//    }

    @Override
    protected void gainDatas() {

        if (NetworkUtils.isConnected()) {

            getServerDatas();

        } else {
            //是否有其他的执行逻辑？
            netWorkError();
//            setEnableLoadmore(refreshLayoutInArchiveDetail, false);

        }

    }

    private void getServerDatas() {

        //String keyWord_upLoad = et_searchInCustomSmall.getText().toString().trim();
        HashMap<String, Object> map = new HashMap<>();
//        map.put(Parameterkey.key, extra_information_manage.getVehicleId());

        //认证状态：0:待联系;1:待认证;2:已认证;3已取消
//        map.put(Parameterkey.status, "2");
//        map.put(Parameterkey.pagination, pagination_upLoad);//传递的页码
//        map.put(Parameterkey.pageSize, Parameterkey.pageSize_default);//,搜索关键字

//        map.put(Parameterkey.latentType, latentType_upLoad);//,潜客类型 1新车;2二手车
//        map.put(Parameterkey.createsource, createsource_upLoad);//客户来源：0预约试驾；1预约看车；2自然到店；3以旧换新
//        map.put(Parameterkey.status, status_upLoad);////跟进状态：0:待联系;1:已分配;2:有意向;3无意向;4成功;5战败;6取消预约
//        map.put(Parameterkey.keyWord, keyWord_upLoad);//,搜索关键字

        AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
        addLogUpLoadInfo.setActivity(mActivityInstance);
        addLogUpLoadInfo.setWhat(ConstantApi.WHAT_GETCARATTESTATIONLISTBYSHOPHISTORY_URL);//请求数字标识
        addLogUpLoadInfo.setUrlPath(ApiService.getShopLatentCustomerList_url);//url地址
        addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
        addLogUpLoadInfo.setToastToUser(true);//展示给用户的标志
        addLogUpLoadInfo.setHashMapParameter(map);

        NetworkManager.getInstance().initRetrofitRxJava()
                .create(ApiService.class)
                .addInformationManage_getById(extra_information_manage.getInformationId())
//                .addInformationManage_getById("")
//                .getCarAttestationListByShopHistory(RequestBody.create(JSON.toJSONString(map, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue),
////                        MediaType.parse(ApiService.HEADER_JSON)))
                .compose(ArchiveDetailActivity.this.bindUntilEvent(ActivityEvent.DESTROY))//
                .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<InformationManageVo>() {
                    @Override
                    public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                        super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);

                        CommUtils.checkMaterialDialog(materialDialog);

                        //这里也是遮盖信息
//                        methodNotSuccessData(what_method, serverCode, serverMessage);

                        if (mDataResources != null && mDataResources.isEmpty()) {

//                            if (refreshLayoutInArchiveDetail != null) {
//                                refreshLayoutInArchiveDetail.setEnableLoadMore(false);
//                            }

                            CommUtils.checkCurrently((ErrorActivity) mActivityInstance,//
                                    serverCode,//
                                    R.drawable.errorsear,//
                                    serverMessage,//
                                    getString(R.string.nulldatanow));
                        }

                        if (!TextUtils.isEmpty(serverMessage)) {
                            ToastUtils.showShort(serverMessage);
                        }

                    }
                })).doOnSubscribe(new Consumer<Disposable>() {
                    @Override
                    public void accept(Disposable disposable) throws Throwable {

                        method_create_materialDialog(mActivityInstance, ConstantSign.TIPS_LOADING);

                        loadingGone();
//                        if (refreshLayoutInArchiveDetail != null) {
//                            refreshLayoutInArchiveDetail.setEnableLoadMore(true);
//                        }
                    }
                }).subscribe(new Consumer<InformationManageVo>() {
                    @Override
                    public void accept(InformationManageVo informationManageVo) throws Throwable {

                        CommUtils.checkMaterialDialog(materialDialog);

                        //外侧携带值内容，为了做本地判断取值用；
                        informationManageVo_temp_local = informationManageVo;

                        //顶部的客户信息：
                        ClientManageVo clientManage = informationManageVo.getClientManage();

                        if (clientManage != null) {
                            method_handler_customer_info(clientManage);
                        }

                        if (informationManageVo != null) {

                            //处理车辆信息
                            method_handler_car_info(informationManageVo);

                            //处理footerview
                            method_handler_footer_view_info(informationManageVo);

                            List<ArchivesManageVo> archivesManageList = informationManageVo.getArchivesManageList();

                            if (archivesManageList != null && !archivesManageList.isEmpty()) {
                                if (mDataResources != null) {
                                    mDataResources.addAll(archivesManageList);
                                }
                            }

                        }

                        //这里也不用管是下拉刷新或者上拉加载更多，直接判断是否为空，
                        if (mDataResources != null && mDataResources.isEmpty()) {
                            //同时禁用加载更多；
//                            if (refreshLayoutInAuthList != null) {
//                                refreshLayoutInAuthList.setEnableLoadMore(false);
//                            }
                            fillNullDataView(StringUtils.getString(R.string.nulldatanow), R.drawable.errorsear);

                        }

                        if (archiveDetailAgreenAdapter != null) {
                            archiveDetailAgreenAdapter.notifyDataSetChanged();
                        }

                        //开始填充预备数据；
                        if (extra_informationManageVoExtra == null) {
                            extra_informationManageVoExtra = new InformationManageVoExtra();
                        }

                        //-----------------------------------------------------------------------------------------------------

                        //设置档案的id,因为修改必须携带
//                      extra_informationManageVoExtra.setVehicleId(informationManageVo.getVehicleId());
                        //2023-11-9 16:50:56 改造为：
                        extra_informationManageVoExtra.setInformationId(informationManageVo.getInformationId());

                        //预备客户信息的数据
                        ClientManageSingleUpLoad clientManageSingleUpLoad = new ClientManageSingleUpLoad();
                        //客户姓名
                        clientManageSingleUpLoad.setClientName(clientManage.getClientName());
                        //客户性别
                        clientManageSingleUpLoad.setGender(clientManage.getGender());
                        //客户年龄
                        clientManageSingleUpLoad.setAge(clientManage.getAge());
                        //客户电话
                        clientManageSingleUpLoad.setPhone(clientManage.getPhone());
                        //微信号
                        clientManageSingleUpLoad.setWechatNumber(clientManage.getWechatNumber());
                        //邮箱信息
                        clientManageSingleUpLoad.setEmail(clientManage.getEmail());
                        //地址信息 住址？
                        clientManageSingleUpLoad.setAddress(clientManage.getAddress());
                        //公司信息
                        clientManageSingleUpLoad.setCompanyDetail(clientManage.getCompanyDetail());
                        //职位信息
                        clientManageSingleUpLoad.setPosition(clientManage.getPosition());

                        extra_informationManageVoExtra.setClientManageSingleUpLoad(clientManageSingleUpLoad);
                        //-----------------------------------------------------------------------------------------------------
                        //预备车辆信息
                        //车牌号
//                        extra_informationManageVoExtra.setLicenseNumber(informationManageVo.getLicenseNumber());
//                        //车架号码
//                        extra_informationManageVoExtra.setVin(informationManageVo.getVin());
//                        //发动机号
//                        extra_informationManageVoExtra.setEngineNum(informationManageVo.getEngineNum());
//
//                        //车辆品牌--的数字格式
//                        extra_informationManageVoExtra.setCarBranch(informationManageVo.getCarBranch());
//                        //车辆品牌--的汉字格式
//                        extra_informationManageVoExtra.setCarBranchName(informationManageVo.getCarBranchName());
//
//                        //车辆车系--的数字形式
//                        extra_informationManageVoExtra.setCarSeries(informationManageVo.getCarSeries());
//                        //车辆车系--的汉字格式
//                        extra_informationManageVoExtra.setCarSeriesName(informationManageVo.getCarSeriesName());
//
//                        //车辆型号
//                        extra_informationManageVoExtra.setCarModel(informationManageVo.getCarModel());

                        //--------------------------------------------------------------------------------------------------------------------------------
                        //车辆列表
                        if (mDataResources_vehicleList != null && !mDataResources_vehicleList.isEmpty()) {
                            mDataResources_vehicleList.clear();
                        }

                        //处理车辆信息，这里是多车辆
                        ArrayList<CarInfoVehicleBean> vehicleList = (ArrayList<CarInfoVehicleBean>) informationManageVo.getVehicleList();

                        //对车辆添加一个编号
                        if (vehicleList != null && !vehicleList.isEmpty()) {

                            for (int indexPositon = 0; indexPositon < vehicleList.size(); indexPositon++) {

                                CarInfoVehicleBean carInfoVehicleBean = new CarInfoVehicleBean();
                                carInfoVehicleBean.setNumber(String.valueOf(indexPositon + 1));
                                //设置档案的id
                                carInfoVehicleBean.setInformationId(informationManageVo.getInformationId());
                                carInfoVehicleBean.setVehicleId(vehicleList.get(indexPositon).getVehicleId());
                                carInfoVehicleBean.setCarBranch(vehicleList.get(indexPositon).getCarBranch());
                                carInfoVehicleBean.setCarBranchName(vehicleList.get(indexPositon).getCarBranchName());
                                carInfoVehicleBean.setCarSeries(vehicleList.get(indexPositon).getCarSeries());
                                LogUtils.d(ConstantSign.LOGCAT_NOMAL + "carInfoVehicleBean.getCarSeriesId->" + carInfoVehicleBean.getCarSeries());

                                carInfoVehicleBean.setCarSeriesName(vehicleList.get(indexPositon).getCarSeriesName());
                                carInfoVehicleBean.setCarModel(vehicleList.get(indexPositon).getCarModel());
                                carInfoVehicleBean.setVin(vehicleList.get(indexPositon).getVin());
                                carInfoVehicleBean.setEngineNum(vehicleList.get(indexPositon).getEngineNum());
                                carInfoVehicleBean.setLicenseNumber(vehicleList.get(indexPositon).getLicenseNumber());

                                if (mDataResources_vehicleList != null) {
                                    mDataResources_vehicleList.add(carInfoVehicleBean);
                                }

                            }

                        }

                        if (archiveFileCarInfoDetailAdapter != null) {
                            archiveFileCarInfoDetailAdapter.notifyDataSetChanged();
                        }

                        //--------------------------------------------------------------------------------------------------------------------------------
                        //预备合同信息-合同列表信息
                        ArrayList<ArchivesManageVo> archivesManageList = (ArrayList<ArchivesManageVo>) informationManageVo.getArchivesManageList();

                        if (archivesManageList != null && !archivesManageList.isEmpty()) {

                            for (ArchivesManageVo archivesManageVo : archivesManageList) {
                                //重新组织合同信息
                                ArchivesManageSingleUpLoad archivesManageSingleUpLoad = new ArchivesManageSingleUpLoad();

                                //合同类型id
                                archivesManageSingleUpLoad.setArchiveTypeId(archivesManageVo.getArchiveTypeId());
                                //合同类型 文字形式；
                                archivesManageSingleUpLoad.setArchivesTypeName(archivesManageVo.getArchivesTypeName());
                                //签约时间
                                archivesManageSingleUpLoad.setSigningDate(archivesManageVo.getSigningDate());
                                //签约人
                                archivesManageSingleUpLoad.setPartyA(archivesManageVo.getPartyA());
                                //签约金额--BigDecimal格式
                                archivesManageSingleUpLoad.setAmount(archivesManageVo.getAmount());
                                //签约金额--string串格式
                                if (archivesManageVo.getAmount() != null) {
                                    archivesManageSingleUpLoad.setAmountString(CommUtils.formatComma2BigDecimal(archivesManageVo.getAmount()).toString());
                                }

                                //合同附件:
                                //List<ArchivesManageFileVo> archivesManageFileVoList = archivesManageVo.getArchivesManageFileVoList();
                                if ((archivesManageVo.getArchivesManageFileVoList() != null) && (!archivesManageVo.getArchivesManageFileVoList().isEmpty())) {
                                    archivesManageSingleUpLoad.getArchivesManageFileVoList().addAll(archivesManageVo.getArchivesManageFileVoList());
                                }

                                extra_informationManageVoExtra.getArchivesManageList().add(archivesManageSingleUpLoad);

                            }

                        }

                        //--------------------------------------------------------------------------------------------------------------------------------
//                        {
//                                "fileType": 1,
//                                "fileTypeName": "身份证",
//                                "images": [
//                                "http://222.222.17.184:8990/resource/file/information/accessory/20240223/2024022310594499745640.png"
//                             ]
//                        },
                        //同样的需要清空档案附件的动态添加的总列表
                        if (mDataResources_archivesManageFileMy != null && !mDataResources_archivesManageFileMy.isEmpty()) {
                            mDataResources_archivesManageFileMy.clear();
                        }

                        if (archiveDetailFootAdapter != null) {
                            archiveDetailFootAdapter.notifyDataSetChanged();
                        }

                        ArrayList<ArchivesManageFileMy> accessorysForApp = informationManageVo.getAccessorysForApp();

                        if (accessorysForApp != null && !accessorysForApp.isEmpty()) {

                            if (mDataResources_archivesManageFileMy != null) {
                                mDataResources_archivesManageFileMy.addAll(accessorysForApp);
                            }

                            //刷新
                            if (archiveDetailFootAdapter != null) {
                                // TODO: 2024/2/26 9:30 刷新列表
                                archiveDetailFootAdapter.notifyDataSetChanged();
                            }

                            //2024-2-26 新增的 填充 动态携带附件的逻辑
                            if (extra_informationManageVoExtra.getAccessorysForApp() != null) {
                                extra_informationManageVoExtra.getAccessorysForApp().addAll(accessorysForApp);
                            }

                        } else {

                            // TODO: 2024/2/26 9:30 手动遍历循环
//                            List<InformationAccessoryVo> informationAccessoryListHandler = informationManageVo.getInformationAccessoryList();
//                            for (InformationAccessoryVo informationAccessoryVo : informationAccessoryListHandler) {
                            //ArchivesManageFileMy archivesManageFileMy  = new ArchivesManageFileMy();
//                        archivesManageFileMy.setFileType(informationAccessoryVo.getFileType());
//                        archivesManageFileMy.setFileTypeName(informationAccessoryVo.getFileTypeName());
//
//                        if (mDataResources_archivesManageFileMy!=null){
//                            mDataResources_archivesManageFileMy.add(archivesManageFileMy);
//                        }

//                            }

                        }


                        //--------------------------------------------------------------------------------------------------------------------------------
                        //预备，底部档案图片信息；
                        List<InformationAccessoryVo> informationAccessoryList = informationManageVo.getInformationAccessoryList();

                        if (extra_informationManageVoExtra.getInformationAccessoryList() != null && !extra_informationManageVoExtra.getInformationAccessoryList().isEmpty()) {
                            extra_informationManageVoExtra.getInformationAccessoryList().clear();
                        }

                        if (informationAccessoryList != null && !informationAccessoryList.isEmpty()) {

                            for (InformationAccessoryVo informationAccessoryVo : informationAccessoryList) {

                                InformationAccessoryUpLoad informationAccessoryUpLoad = new InformationAccessoryUpLoad();

                                //设置附件的类型 2024-2-26 16:09:56
                                informationAccessoryUpLoad.setFileType(informationAccessoryVo.getFileType());
                                //设置附件的类型的名称 2024-2-26 16:09:59
                                informationAccessoryUpLoad.setFileTypeName(informationAccessoryVo.getFileTypeName());

                                informationAccessoryUpLoad.setFilePath(informationAccessoryVo.getFilePath());
                                informationAccessoryUpLoad.setFileName(informationAccessoryVo.getFileName());
                                informationAccessoryUpLoad.setFileSize(informationAccessoryVo.getFileSize());
                                informationAccessoryUpLoad.setUrlPrefix(informationAccessoryVo.getUrlPrefix());
                                informationAccessoryUpLoad.setUrl(informationAccessoryVo.getUrl());

                                //目的是为了下一页编辑【档案附件】的时候携带上传。
                                extra_informationManageVoExtra.getInformationAccessoryList().add(informationAccessoryUpLoad);

                            }

                            //手动遍历一个我本地用来处理底部适配器的逻辑
                            //mDataResources_archivesManageFileMy


                        }

                        //-----------------------------------------------------------------------------------------------------------------------------------------------------------
                        //预备， 档案附件的仅仅是图片的纯粹路径信息
                        List<String> informationAccessoryUrlList = informationManageVo.getInformationAccessoryUrlList();

                        //2023-11-13 11:15:48发现bug:要将旧数据清除掉
                        if (extra_informationManageVoExtra.getInformationAccessoryUrlList() != null && !extra_informationManageVoExtra.getInformationAccessoryUrlList().isEmpty()) {
                            extra_informationManageVoExtra.getInformationAccessoryUrlList().clear();
                        }

                        if (informationAccessoryUrlList != null && !informationAccessoryUrlList.isEmpty()) {
                            extra_informationManageVoExtra.getInformationAccessoryUrlList().addAll(informationAccessoryUrlList);
                        }
                        //----------------------------------------------------------------------------------------------------------------------------------------------------------

                        //打印这个传递值
                        LogUtils.json(ConstantSign.LOGCAT_NOMAL + "--extra_informationManageVoExtra-->", extra_informationManageVoExtra);

                        //--------------------------------------------------------------------------------------------------------------------------------

                    }
                }, new ErrorConsumer() {

                    @Override
                    protected void error(ApiException apiException) {
                        //页面报错；
                    }
                });

    }

    //处理底部footerview
    private void method_handler_footer_view_info(InformationManageVo _informationManageVo) {

        ArrayList<String> informationAccessoryUrlList = (ArrayList<String>) _informationManageVo.getInformationAccessoryUrlList();

        if (informationAccessoryUrlList != null && !informationAccessoryUrlList.isEmpty()) {

            if (npl_item_moment_photos_file_detail != null) {
                npl_item_moment_photos_file_detail.setData(informationAccessoryUrlList);
            }

        }

    }

    //fill-车辆信息
    private void method_handler_car_info(InformationManageVo _informationManageVo) {

        Delivery.getInstance().post(new Runnable() {
            @Override
            public void run() {

                //车牌号
//                CommUtils.setText(textViewFileCarCard, _informationManageVo.getLicenseNumber());
//                //车架号码
//                CommUtils.setText(textViewFileCarFrame, _informationManageVo.getVin());
//                //发动机号
//                CommUtils.setText(textViewFileCarMotor, _informationManageVo.getEngineNum());
//                //品牌型号
//                CommUtils.setText(textViewFileCarBrandModel, _informationManageVo.getCarBranchName());
//                //车辆车系
//                CommUtils.setText(textViewFileCarModelLine, _informationManageVo.getCarSeriesName());
//                //车辆型号
//                CommUtils.setText(textViewFileCarModelSmall, _informationManageVo.getCarModel());

            }
        });

    }

    //fill-填充档案详情之中
    private void method_handler_customer_info(ClientManageVo _clientManage) {

        Delivery.getInstance().post(new Runnable() {
            @Override
            public void run() {

                //客户姓名
                CommUtils.setText(textViewCustomerPersonName, _clientManage.getClientName());
                //客户性别
                String genderType = _clientManage.getGender();
//                LeadGender {
//                    LEAD_GENDER_MEN("0", "男"),
//                    LEAD_GENDER_WOMEN("1", "女"),
//                    LEAD_GENDER_UNKNOW("2", "未知");//未知
                if (TextUtils.equals(genderType, LeadGender.LEAD_GENDER_MEN.getIndex())) {
                    CommUtils.setText(textViewCustomerPersonSex, LeadGender.LEAD_GENDER_MEN.getValue());
                } else if (TextUtils.equals(genderType, LeadGender.LEAD_GENDER_WOMEN.getIndex())) {
                    CommUtils.setText(textViewCustomerPersonSex, LeadGender.LEAD_GENDER_WOMEN.getValue());
                } else if (TextUtils.equals(genderType, LeadGender.LEAD_GENDER_UNKNOW.getIndex())) {
                    CommUtils.setText(textViewCustomerPersonSex, LeadGender.LEAD_GENDER_UNKNOW.getValue());
                }

                //客户年龄
                CommUtils.setText(textViewCustomerPersonYear, _clientManage.getAge());
                //外侧用到
                phoneNumber_outSide = _clientManage.getPhone();
                //客户电话
                CommUtils.setText(textViewCustomerPersonPhone, StringCodeUtils.mobileEncrypt(_clientManage.getPhone()));
                //微信号
                CommUtils.setText(textViewCustomerPersonWechat, _clientManage.getWechatNumber());
                //邮箱信息
                CommUtils.setText(textViewCustomerPersonEmail, _clientManage.getEmail());
                //地址信息 住址？
                CommUtils.setText(textViewCustomerPersonAddress, _clientManage.getAddress());
                //公司信息
                CommUtils.setText(textViewCustomerPersonCompany, _clientManage.getCompanyDetail());
                //职位信息
                CommUtils.setText(textViewCustomerPersonJob, _clientManage.getPosition());

            }
        });

    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEventMainThreadInArchiveDetail(EventArchiveDetail eventArchiveDetail) {

        if (eventArchiveDetail != null) {

            if (eventArchiveDetail.getMessage() == ExtraValue.EVENTBUS_EVENT_TO_REFRESH_ARCHIVEFILE_DETAIL) {

                //如果发起搜索，要重置 第1页
//                pagination_upLoad = Parameterkey.pageNum_default_first;

                //清空历史数据
                if (mDataResources != null && !mDataResources.isEmpty()) {
                    mDataResources.clear();
                }

                if (archiveDetailAgreenAdapter != null) {
                    archiveDetailAgreenAdapter.notifyDataSetChanged();
                }

                getServerDatas();

            }

        }

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

        if (mCurrentClickNpl != null) {
            mCurrentClickNpl = null;
        }

        if (extra_informationManageVoExtra != null) {
            extra_informationManageVoExtra = null;
        }

        if (mDataResources != null && !mDataResources.isEmpty()) {
            mDataResources.clear();
        }

        if (mDataResources_archivesManageFileMy != null && !mDataResources_archivesManageFileMy.isEmpty()) {
            mDataResources_archivesManageFileMy.clear();
        }

        if (archiveDetailAgreenAdapter != null) {
            archiveDetailAgreenAdapter.notifyDataSetChanged();
            archiveDetailAgreenAdapter = null;
        }

        EventBus.getDefault().unregister(this);
    }

    @Override
    protected void methodBack() {
        if (ActivityUtils.isActivityAlive(this)) {
            ActivityUtils.finishActivity(this);
        }
    }

    @Override
    public void processExtraData() {

        Bundle extras_bundle = this.getIntent().getExtras();

        if (extras_bundle != null) {

            //flag_jumpfrom_where_type = extras_bundle.getString(ExtraKey.EXTRA_JUMPFROM_WHERE_TYPE);

            extra_information_manage = extras_bundle.getParcelable(ExtraKey.EXTRA_INFORMATION_MANAGE);

            LogUtils.json(ConstantSign.LOGCAT_NOMAL + "携带的档案的内容是", extra_information_manage);

        }

    }

    /**
     * 图片预览，兼容6.0动态权限
     */
    @AfterPermissionGranted(PRC_PHOTO_PREVIEW)
    private void photoPreviewWrapper() {

        if (mCurrentClickNpl == null) {
            return;
        }

        //下载图片需要的权限提示；

        try {

//            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {

            //do
            String[] perms = {Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE};

            if (EasyPermissions.hasPermissions(this, perms)) {

//                    File downloadDir = new File(Environment.getExternalStorageDirectory(), ConstantSign.BGAPHOTOPICKERDOWNLOAD);//BGAPhotoPickerDownload
//                    BGAPhotoPreviewActivity.IntentBuilder photoPreviewIntentBuilder = new BGAPhotoPreviewActivity.IntentBuilder(this);
////            if (mDownLoadableCb.isChecked()) {
//                    // 保存图片的目录，如果传 null，则没有保存图片功能
//                    photoPreviewIntentBuilder.saveImgDir(downloadDir);
////        }
//
//                    if (mCurrentClickNpl.getItemCount() == 1) {
//                        // 预览单张图片
//                        photoPreviewIntentBuilder.previewPhoto(mCurrentClickNpl.getCurrentClickItem());
//                    } else if (mCurrentClickNpl.getItemCount() > 1) {
//                        // 预览多张图片
//                        photoPreviewIntentBuilder.previewPhotos(mCurrentClickNpl.getData())
//                                .currentPosition(mCurrentClickNpl.getCurrentClickItemPosition()); // 当前预览图片的索引
//                    }
//                    startActivity(photoPreviewIntentBuilder.build());

                CommTools.photoPreviewIntent(mActivityInstance, ArchiveDetailActivity.this, mCurrentClickNpl);

            } else {
                EasyPermissions.requestPermissions(this, getString(R.string.imagenicelook), PRC_PHOTO_PREVIEW, perms);
            }

//            }

//            else {
//
//                //do
//                String[] perms = {Manifest.permission.READ_EXTERNAL_STORAGE};
//
//                if (EasyPermissions.hasPermissions(this, perms)) {
//
//
//                } else {
//                    EasyPermissions.requestPermissions(this, getString(R.string.imagenicelook), PRC_PHOTO_PREVIEW, perms);
//                }
//
//            }

        } catch (Exception e) {
            //catch
            e.printStackTrace();
        }


    }

    private void photoPreviewIntentXXPermissions() {

        if (!XXPermissions.isGranted(ArchiveDetailActivity.this, com.hjq.permissions.Permission.READ_MEDIA_IMAGES)) {

            CommUtils.checkMaterialDialog(materialDialog);

            materialDialog = CommUtils.authorityRequest(mActivityInstance, ConstantSign.MATERIALDIALOG_AUTHORITY_CONTENT_ALBUM, new AuthorityCallbackListener() {
                @Override
                public void doSomeThing() {

                    XXPermissions.with(ArchiveDetailActivity.this)
                            // 适配分区存储应该这样写
                            //.permission(Permission.Group.STORAGE)
                            // 不适配分区存储应该这样写
//                    .permission(com.hjq.permissions.Permission.CAMERA)//
                            .permission(com.hjq.permissions.Permission.READ_MEDIA_IMAGES)//
//                  .permission(com.hjq.permissions.Permission.READ_MEDIA_VIDEO)//
//                  .permission(com.hjq.permissions.Permission.READ_MEDIA_AUDIO)//
                            //).permission(com.hjq.permissions.Permission.MANAGE_EXTERNAL_STORAGE
                            .interceptor(new PermissionInterceptor())
                            .request(new OnPermissionCallback() {

                                @Override
                                public void onGranted(@NonNull List<String> permissions, boolean allGranted) {

                                    if (!allGranted) {
                                        return;
                                    }

                                    Toaster.show(String.format(getString(R.string.demo_obtain_permission_success_hint), PermissionNameConvert.getPermissionString(ArchiveDetailActivity.this, permissions)));

                                    CommTools.photoPreviewIntent(mActivityInstance, ArchiveDetailActivity.this, mCurrentClickNpl);

                                }
                            });

                    CommUtils.checkMaterialDialog(materialDialog);

                }
            });

        } else {

            CommTools.photoPreviewIntent(mActivityInstance, ArchiveDetailActivity.this, mCurrentClickNpl);

        }

    }

    //执行预览的intent
//    private void photoPreviewIntent() {
//
//        // File downloadDir = new File(Environment.getExternalStorageDirectory(), ConstantSign.BGAPHOTOPICKERDOWNLOAD);//BGAPhotoPickerDownload
//        File downloadDir = new File(PathUtils.getExternalAppFilesPath(), ConstantSign.BGAPHOTOPICKERDOWNLOAD);//BGAPhotoPickerDownload
//
//        BGAPhotoPreviewActivity.IntentBuilder photoPreviewIntentBuilder = new BGAPhotoPreviewActivity.IntentBuilder(this);
//
////            if (mDownLoadableCb.isChecked()) {
//        // 保存图片的目录，如果传 null，则没有保存图片功能
//        photoPreviewIntentBuilder.saveImgDir(downloadDir);
////        }
//
//        if (mCurrentClickNpl.getItemCount() == 1) {
//            // 预览单张图片
//            photoPreviewIntentBuilder.previewPhoto(mCurrentClickNpl.getCurrentClickItem());
//        } else if (mCurrentClickNpl.getItemCount() > 1) {
//            // 预览多张图片
//            photoPreviewIntentBuilder.previewPhotos(mCurrentClickNpl.getData())
//                    .currentPosition(mCurrentClickNpl.getCurrentClickItemPosition()); // 当前预览图片的索引
//        }
//
//        startActivity(photoPreviewIntentBuilder.build());
//
//    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
    }

    @Override
    public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {

    }

    @Override
    public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {
        if (requestCode == PRC_PHOTO_PREVIEW) {
            Toast.makeText(this, getString(R.string.image_preview), Toast.LENGTH_SHORT).show();
        }
    }
}